package com.houzehui.stock.controller;

import com.houzehui.stock.config.MsgResult;
import com.houzehui.stock.dao.SkuStockDao;
import com.houzehui.stock.entity.SkuStock;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/stock")
public class SkuStockController {

    @Resource
    SkuStockDao skuStockDao;
    @GetMapping("getStockBySkuId/{skuId}")
    public MsgResult getStockBySkuId(@PathVariable(value = "skuId") Long skuId){
        SkuStock bySkuId = skuStockDao.findBySkuId(skuId);
        long stockkc = bySkuId.getTotalstock() - bySkuId.getOccupyStock();
        return MsgResult.succeed(stockkc);
    }

//    @GetMapping("addoccupyStock/{skuId}")
//    public void addoccupyStock(@PathVariable(value = "skuId")Long skuId){
//        SkuStock skuStock = new SkuStock();
//        skuStock.
//    }


}
